<template>
  <div class="points">
    <van-nav-bar title="积分记录" left-text="返回" left-arrow @click-left="$router.push('/mine')" />

    <van-cell-group>
      <van-cell v-for="item in points_list"
      :value-class="item.type? 'green' : 'red'"
      :key="item.id"
      :title="item.remark"
      :value="points_text(item.points, item.type)"
      :label="item.create_time" />
      </van-cell-group>

    <is-empty v-if="points_list.length == 0">还没有积分记录</is-empty>
  </div>
</template>

<script>
import IsEmpty from '@/components/include/empty/';

export default {
  components: {
    [IsEmpty.name]: IsEmpty
  },

  data() {
    return {
      points_list: []
    };
  },

  computed: {
    points_text() {
      return function(val,type){
        return  type == 1 ? '积分 +' +val : '积分 -' + val;
      }
    }
  },

  mounted() {
    this.loadLists();
  },

  methods: {
    loadLists() {
      this.apiPost('/shop.member/points', {}).then(res => {
        this.points_list = res.data;
      });
    }
  }
};
</script>

<style lang="scss" scoped="scoped">

  .green{
    color: green;
  }
  .red{
    color: red;
  }
</style>
